{% load debate_tags humanize i18n %}

<div class="card">
  <div class="list-group list-group-flush">

    {% if not feedback.confirmed %}
      <div class="list-group-item list-group-item-warning h6" data-toggle="tooltip"
           title="{% trans 'This is most likely because the team or adjudicator who submitted this feedback has submitted several times on the same person; or because a team has submitted feedback on multiple panellists (rather than just the orallist).' %}">
      {% trans "Unconfirmed; will not affect this adjudicator's score." %}
      </div>
    {% endif %}
    {% if feedback.ignored %}
      <div class="list-group-item list-group-item-warning h6" data-toggle="tooltip"
           title="{% trans 'The feedback is counted for the adjudicator, but is not taken into account when calculating scores.' %}">
      {% trans "Ignored; will not affect this adjudicator's score." %}
      </div>
    {% endif %}
    {% if not feedback.debate_adjudicator.get_type_display %}
      <div class="list-group-item list-group-item-danger h6">
        {% trans "This feedback is submitted on an adjudicator but it looks like they have been since been removed from the debate. You should probably go to the Edit Database area and delete this feedback." %}
      </div>
    {% endif %}
    <div class="list-group-item h5">
      <span class="badge float-right
            {% if feedback.score <= score_thresholds.low_score %}badge-danger
            {% elif feedback.score <= score_thresholds.medium_score %}badge-warning
            {% elif feedback.score > score_thresholds.high_score %}badge-success
            {% else %}badge-primary{% endif %}" data-toggle="tooltip"
            title="{% trans "The score given in this piece of feedback." %}">
        {% blocktrans trimmed with score=feedback.score round=feedback.round.abbreviation %}
          {{ round }} {{ score }}
        {% endblocktrans %}
      </span>
      {% blocktrans trimmed with adjudicator=feedback.adjudicator.name %}
        On {{ adjudicator }}
      {% endblocktrans %}
    </div>
    <div class="list-group-item h5">
      {% blocktrans trimmed with as=feedback.debate_adjudicator.get_type_display %}
        <span class="text-secondary small">Received as {{ as }}</span>
      {% endblocktrans %}
      <span class="badge float-right badge-secondary" data-toggle="tooltip">
        {% blocktrans trimmed with base=feedback.adjudicator.base_score|floatformat:"1" %}
          Base {{ base }}
        {% endblocktrans %}
      </span>
    </div>
    <div class="list-group-item h5">
      {% if feedback.source_adjudicator %}
        {% blocktrans trimmed with source=feedback.source_adjudicator.adjudicator.name relationship=feedback.source_adjudicator.get_type_display %}
          From {{ source }} <span class="text-secondary small">(their {{ relationship }})</span>
        {% endblocktrans %}
      {% elif feedback.source_team %}
        {% blocktrans trimmed with source=feedback.source_team.team.short_name relationship=feedback.source_team.get_result_display|safe side=feedback.source_team.get_side_abbr %}
          From {{ source }} <span class="text-secondary small">({{ relationship }} from {{ side }})</span>
        {% endblocktrans %}
      {% else %}
        {% trans "From unknown" %}
      {% endif %}
    </div>
    {% for item in feedback.items %}
      <div class="list-group-item small">
        {% if item.question.answer_type == item.question.ANSWER_TYPE_BOOLEAN_CHECKBOX or item.question.answer_type == item.question.ANSWER_TYPE_BOOLEAN_SELECT %}
          {% if item.answer %}
            <i data-feather="check" class="text-success"></i>
          {% else %}
            <i data-feather="x" class="text-danger"></i>
          {% endif %}
          <span title="{{ item.question.text }}" class="text-heading" data-toggle="tooltip">
            {{ item.question.reference }}
          </span>
        {% elif item.question.answer_type == item.question.ANSWER_TYPE_FLOAT %}
          <span class="text-secondary">{{ item.question.text }}</span>
          <div class="text-heading">{{ item.answer|floatformat:"2" }}</div>
        {% elif item.question.answer_type == item.question.ANSWER_TYPE_LONGTEXT %}
          <div class="text-heading">{{ item.answer }}</div>
        {% elif item.question.answer_type == item.question.ANSWER_TYPE_MULTIPLE_SELECT %}
          <span class="text-secondary">{{ item.question.text }}</span>
          <div class="text-heading">{{ item.answer|join:", " }}</div>
        {% else %}
          <span class="text-secondary">{{ item.question.text }}</span>
          <div class="text-heading">{{ item.answer }}</div>
        {% endif %}
      </div>
    {% endfor %}
    <div class="list-group-item text-secondary">
      <span class="pt-3 small">
        {% blocktrans trimmed with time=feedback.timestamp|naturaltime %}
          {{ time }}
        {% endblocktrans %}
      </span>
      <span class="float-right" data-toggle="tooltip"
            title="{% trans "Unconfirmed feedback is not counted as having been submitted and does not affect this adjudicator's score." %}">
        <form method="POST" action="{% tournamenturl 'adjfeedback-confirm-feedback' feedback.id %}" class='text-secondary'>
          {% csrf_token %}
          <input type="hidden" name="next" value="{{ request.path }}">
          <button type="submit" class="btn btn-link text-muted pl-3 p-0">
            <small>{% if feedback.confirmed %}{% trans "Un-confirm" %}{% else %}{% trans "Confirm" %}{% endif %}</small>
          </button>
        </form>
      </span>
      <span class="float-right" data-toggle="tooltip"
            title="{% trans "Ignored feedback is counted as having been submitted, but does not affect this adjudicator's score." %}">
        <form method="POST" action="{% tournamenturl 'adjfeedback-ignore-feedback' feedback.id %}" class='text-secondary'>
          {% csrf_token %}
          <input type="hidden" name="next" value="{{ request.path }}">
          <button type="submit" class="btn btn-link text-muted p-0">
            <small>{% if feedback.ignored %}{% trans "Un-ignore" %}{% else %}{% trans "Ignore" %}{% endif %}</small>
          </button>
        </form>
      </span>
    </div>

  </div>
</div>
